import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
function listAverageScorePage(data) {
    return fetch({
        url: '/api/scoremanagementservice/studentScoreCount/listAvgScorePage',
        method: 'post',
        data: data
    });
}

function myScoreStatistics(data) {
    return fetch({
        url:
            '/api/scoremanagementservice/studentScoreCount/queryStudentAvgPoint',
        method: 'post',
        data: data
    });
}

/**
 * export average Score
 * @param {*} params
 */
function avgScoreExport(params) {
    return fetch ({
        url:`/api/scoremanagementservice/studentScoreCount/avgScoreExport`,
        method:'post',
        data: params,
    })
}

function downStatus(key){//导出
    return fetch ({
        url:`/api/scoremanagementservice/studentScoreCount/queryExportProgressByKey?key=${key}`,
        method:'get',
    })
}

/**
 * student degree info export
 * @param {*} data
 */
function studentDegreeInfoExport(data) {
    const url =
        'api/scoremanagementservice/studentScoreCount/studentAvgPointExport';
    let queryParams = '';
    for (let item in data) {
        if (data[item] === '') {
            continue;
        }
        queryParams += `${item}=${data[item]}&`;
    }
    queryParams = queryParams.substring(0, queryParams.lastIndexOf('&'));
    window.open(`${url}?${queryParams}`);
}


const studentAverageScoreApi = {
    studentDegreeInfoExport,
    listAverageScorePage,
    myScoreStatistics,
    avgScoreExport,
    downStatus
};

export default studentAverageScoreApi;
